package org.dant.ant.extension.net.processors;

import org.dant.ant.extension.net.Processor;
import org.dant.ant.extension.tasks.internal.RemoteCommand;
import org.dant.ant.extension.tasks.internal.RemoteResponse;
import org.dant.ant.extension.tasks.commands.CommandsConstants;

public class ShutdownExecProcessor extends ExecProcessor implements Processor {

  public void process(RemoteCommand req, RemoteResponse response) {
    System.out.println("Shutdown Exec requied from : " + req.getSourceHost());
    response.setCommandType(req.getName());
    if (CommandsConstants.DANT_CMD_SHUTDOWN_EXEC.equals(req.getName())) {
      StartCxxApp cxxApp = setup(req);
      String processKey = cxxApp.getProcessKey();
      shutdown(processKey, response);
      response.setCommand(processKey);
    } else {
      response.setSuccess(false);
      response.setResult("Required a EXEC command , but is not a EXEC command");
    }
  }
}
